/**
 * 
 */
package com.toncen.samepms.fisher.filter;

import java.util.ArrayList;
import java.util.List;

import com.toncen.samepms.fisher.condition.OrganizationTypeLikeCondtion;
import com.toncen.samepms.fisher.condition.OrganizationTypeNotLikeCondtion;
import com.toncen.samepms.system.dao.CodeDao;
import com.toncen.samepms.system.domain.Code;
import com.toncen.samepms.system.domain.CodeItem;
import com.sky.fisher.condition.AbstractCondition;
import com.sky.fisher.filter.AbstractColumnFilter;
import com.sky.fisher.filter.Options;
import com.sky.fisher.model.CommonColumnModel;

/**
 * 描述：组织类型过滤器
 * 
 * @author tch
 * 
 */
public class OrganizationTypeColumnFilter extends AbstractColumnFilter {
	private AbstractCondition[] conditons = new AbstractCondition[] { new OrganizationTypeLikeCondtion(),
			new OrganizationTypeNotLikeCondtion() };

	/**
	 * 
	 */
	public OrganizationTypeColumnFilter() {
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.sky.fisher.filter.AbstractColumnFilter#getConditons()
	 */
	@Override
	protected AbstractCondition[] getConditons() {
		return conditons;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.sky.fisher.filter.AbstractColumnFilter#getDefaultCondition()
	 */
	@Override
	public AbstractCondition getDefaultCondition() {
		return new OrganizationTypeLikeCondtion();
	}

	@Override
	public String getValidateMessage() {
		return null;
	}

	@Override
	public String getValidatePattern() {
		return null;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.sky.fisher.filter.AbstractColumnFilter#getValueOptions(com.sky.fisher.model.CommonColumnModel)
	 */
	public List<Options> getValueOptions(CommonColumnModel column) throws Exception {
		List<Options> valueOptions = new ArrayList<Options>();
		CodeDao codeDao = new CodeDao();
		String code = "organization_type";
		Code codeBean = codeDao.getByCode(code);
		if (codeBean == null) {
			throw new Exception("编码【" + code + "】不存在，请与系统管理员联系！");
		}
		for (CodeItem item : codeBean.getCodeItemList()) {
			valueOptions.add(new Options(item.getValue(), item.getName()));
		}
		return valueOptions;
	}
}
